package com.ruoyi.StarStudio.Utils;

import com.ruoyi.StarStudio.Domain.MessageConstant;
import com.ruoyi.StarStudio.Domain.Meteorology;
import com.ruoyi.StarStudio.Domain.Soil;
import com.ruoyi.StarStudio.Domain.Warning;

public class WarningCompareUtils {

    public static String MeteorologyCompare(Meteorology mete, Warning warning){
        StringBuffer ComRes = new StringBuffer("");

        if (mete.getMeteorology_temperature() < warning.getMeteorology_temperatureLowerLimit()){
            ComRes.append(MessageConstant.METEOROLOGY_TEMPERATURE_TOO_LOW);
        }
        if (mete.getMeteorology_temperature() > warning.getMeteorology_temperatureUpperLimit()){
            ComRes.append(MessageConstant.METEOROLOGY_TEMPERATURE_TOO_HIGH);
        }
        if (mete.getMeteorology_humidity() < warning.getMeteorology_humidityLowerLimit()){
            ComRes.append(MessageConstant.METEOROLOGY_HUMIDITY_TOO_LOW);
        }
        if (mete.getMeteorology_humidity() > warning.getMeteorology_humidityUpperLimit()){
            ComRes.append(MessageConstant.METEOROLOGY_HUMIDITY_TOO_HIGH);
        }
        if (mete.getMeteorology_co2() < warning.getMeteorology_co2LowerLimit()){
            ComRes.append(MessageConstant.METEOROLOGY_CO2_TOO_LOW);
        }
        if (mete.getMeteorology_co2() > warning.getMeteorology_co2UpperLimit()){
            ComRes.append(MessageConstant.METEOROLOGY_CO2_TOO_HIGH);
        }
        if (mete.getMeteorology_illuminance() < warning.getMeteorology_illuminanceLowerLimit()){
            ComRes.append(MessageConstant.METEOROLOGY_ILLUMINANCE_TOO_LOW);
        }
        if (mete.getMeteorology_illuminance() > warning.getMeteorology_illuminanceUpperLimit()){
            ComRes.append(MessageConstant.METEOROLOGY_ILLUMINANCE_TOO_HIGH);
        }
        if (mete.getMeteorology_rainfall() < warning.getMeteorology_rainfallLowerLimit()){
            ComRes.append(MessageConstant.METEOROLOGY_RAINFALL_TOO_LOW);
        }
        if (mete.getMeteorology_rainfall() > warning.getMeteorology_rainfallUpperLimit()){
            ComRes.append(MessageConstant.METEOROLOGY_RAINFALL_TOO_HIGH);
        }
        if (mete.getMeteorology_wind_speed() < warning.getMeteorology_windSpeedLowerLimit()){
            ComRes.append(MessageConstant.METEOROLOGY_WIND_SPEED_TOO_LOW);
        }
        if (mete.getMeteorology_wind_speed() > warning.getMeteorology_windSpeedUpperLimit()){
            ComRes.append(MessageConstant.METEOROLOGY_WIND_SPEED_TOO_HIGH);
        }

        return ComRes.toString();
    }

    public static String SoilCompare(Soil soil, Warning warning){
        StringBuffer ComRes = new StringBuffer("");

        if (soil.getSoil_temperature() < warning.getSoil_temperatureLowerLimit()){
            ComRes.append(MessageConstant.SOIL_TEMPERATURE_TOO_LOW);
        }
        if (soil.getSoil_temperature() > warning.getSoil_temperatureUpperLimit()){
            ComRes.append(MessageConstant.SOIL_TEMPERATURE_TOO_HIGH);
        }
        if (soil.getSoil_moisture() < warning.getSoil_moistureLowerLimit()){
            ComRes.append(MessageConstant.SOIL_MOISTURE_TOO_LOW);
        }
        if (soil.getSoil_moisture() > warning.getSoil_moistureUpperLimit()){
            ComRes.append(MessageConstant.SOIL_MOISTURE_TOO_HIGH);
        }
        if (soil.getSoil_ph() < warning.getSoil_phLowerLimit()){
            ComRes.append(MessageConstant.SOIL_PH_TOO_LOW);
        }
        if (soil.getSoil_ph() >warning.getSoil_phUpperLimit()){
            ComRes.append(MessageConstant.SOIL_PH_TOO_HIGH);
        }

        return ComRes.toString();
    }

}
